package org.gitos.cloud.server.rpc;

import com.google.common.collect.Maps;
import org.gitos.cloud.domain.comm.Constant;

import java.util.HashMap;

/**
 * Created by hc on 2016/3/29 0029.
 */
public class CommonMethod {

    protected HashMap<String, Object> success(Object data) {
        HashMap<String, Object> ret = Maps.newHashMap();
        ret.put(Constant.RET_STATE, 200);
        ret.put(Constant.RET_DATA, data);
        return ret;
    }

    protected HashMap<String, Object> fail(Object msg) {
        HashMap<String, Object> ret = Maps.newHashMap();
        ret.put(Constant.RET_STATE, 500);
        ret.put(Constant.RET_MSG, msg);
        return ret;
    }

    protected HashMap<String, Object> judge(boolean b) {
        if (b) {
            return success(b);
        } else {
            return fail(b);
        }
    }
}
